/**
paas.sql * @开发版权 
 * @项目名称 VFCloud-PaaS
 * @版本信息 v1.0
 * @开发人员 zhous
 * @开发日期 2023-02-21
 * @修订日期
 * @描述  VFCloudPaasApplication
 */
package com.vf.cloud.paas;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
import com.vf.cloud.paas.common.server.MongodbServer;
import com.vf.cloud.paas.common.server.RedisServer;
import com.vf.cloud.paas.common.util.MYSQLUtil;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@EnableAsync
@SpringBootApplication
public class VFCloudPaaSApplication implements InitializingBean{
	
	public static void main(String[] args) {
		SpringApplication.run(VFCloudPaaSApplication.class, args);
	}
	
	@Value("${agent.install.path}")
	private String softPath;

	@Value("${mysql.port}")
	private int mysqlPort;
	
	@Value("${spring.redis.port}")
	private int redisPort;
	
	@Value("${spring.data.mongodb.port}")
	private int mongodbPort;
	
	@Override
	public void afterPropertiesSet() throws Exception {
		boolean isStartMYSQL = MYSQLUtil.startMYSQL(softPath, mysqlPort);
		if (!isStartMYSQL) {
			log.info("MySQL startup failed.");
			return;
		}
		new RedisServer(softPath, redisPort).run();
		new MongodbServer(softPath, mongodbPort).run();
	}

}
